home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Installation Tools & Overlays 2002 November
/
SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso
/
dist
/
infosearch.idb
/
usr
/
lib
/
infosearch
/
bin
/
book2html.z
/
book2html
Wrap
Text File
|
2002-10-15
|
3KB
|
145 lines
#!/usr/bin/perl
#
# Copyright 1996-2002, Silicon Graphics, Inc.
# All Rights Reserved.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
# the contents of this file may not be disclosed to third parties, copied or
# duplicated in any form, in whole or in part, without the prior written
# permission of Silicon Graphics, Inc.
#
# RESTRICTED RIGHTS LEGEND:
# Use, duplication or disclosure by the Government is subject to restrictions
# as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
# and Computer Software clause at DFARS 252.227-7013, and/or in similar or
# successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
# rights reserved under the Copyright Laws of the United States.
#
# --------
# book2html
# ---------
# filter books
#
# Usage:
# book2html [-r <root>] [-db <db>] [-h <highlight>] /<std_pth>/<file>
#
# requires perl5 and book2html.pl
#
$| = 1;
use strict;
# globals
#
package InfoSearch;
$InfoSearch::COLLECTION = $ENV{'COLLECTION'};
$InfoSearch::_TR = $ENV{'TOOLROOT'};
$InfoSearch::_WEB = ($ENV{'REQUEST_METHOD'} ne '' ? 1 : 0);
$InfoSearch::_DB = 'bks';
require 'book2html.pl';
&main(@ARGV);
exit(0);
#######################################################################
#
# void main()
#
#######################################################################
sub main {
my(@argv) = @_;
unless ($argv[0]) {
print "book2html: no arguments" if (${InfoSearch::_WEB} == 0);
return;
}
# root = /d1
# pth = /usr/share/Insight/library/SGI_bookshelves
#
my($fname, $bk_root, $bk_pth, $srch_str) = '';
my($i) = 0;
while($i < (@argv + 0)) {
if ($argv[$i] eq "-h") {
splice(@argv, $i, 1);
if( $argv[$i] ne '' ) {
$srch_str = $argv[$i];
splice(@argv, $i, 1);
}
} elsif ($argv[$i] eq "-r") {
splice(@argv, $i, 1);
if( $argv[$i] ne '' ) {
$bk_root = $argv[$i];
splice(@argv, $i, 1);
}
} elsif ($argv[$i] eq "-p") {
splice(@argv, $i, 1);
if( $argv[$i] ne '' ) {
$bk_pth = $argv[$i];
splice(@argv, $i, 1);
}
} elsif ($argv[$i] eq "-db") {
splice(@argv, $i, 1);
if( $argv[$i] ne '' ) {
$InfoSearch::_DB = $argv[$i];
splice(@argv, $i, 1);
}
} else {
$i++;
}
}
# take whatever is left
#
$fname = join(' ', @argv);
# Set the path for security and taint checking.
#
$ENV{'PATH'} = "${InfoSearch::_TR}/usr/sbin:" .
"${InfoSearch::_TR}/usr/bin:" .
"${InfoSearch::_TR}/bin:/usr/sbin:/usr/bin:/bin";
# check (again!)
#
my($OK_CHARS) = "-a-zA-Z0-9_.*:;\+\/τ";
$fname =~ s/[^$OK_CHARS]//go;
if( $fname =~ /\.\./ || $fname =~ /^\/etc/ || $fname =~ /\&/
||
$fname =~ /\;/ || $fname =~ /\|/ || $fname =~ /\,/
||
$fname =~ /\>/ || $fname =~ /\</ ) {
print "book2html: Illegal document access" if (${InfoSearch::_WEB} == 0);
return;
}
$bk_pth =~ s/[^$OK_CHARS]//go;
$bk_root =~ s/[^$OK_CHARS]//go;
# default path
#
if( $bk_pth eq '' ) {
$bk_pth = '/usr/share/Insight/library/SGI_bookshelves';
}
&book2html($bk_root, $bk_pth, $fname, $srch_str);
return;
}